﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using WanDa.IDal;

namespace WanDa.Bll
{
    public abstract class BaseBll<T> where T : class,new()
    {
        public BaseBll()
        {
            SetDal();
        }
        public abstract void SetDal();
        public IBaseDal<T> Dal { get; set; }
        public bool Add(T model)
        {
            Dal.Add(model);
            return Dal.SaveChanges();
        }
        public bool Del(int id)
        {
            Dal.Del(id);
            return Dal.SaveChanges();
        }
        public bool Upd(T model)
        {
            Dal.Upd(model);
            return Dal.SaveChanges();
        }
        public IQueryable<T> Show(Expression<Func<T, bool>> whereLambda)
        {
            return Dal.Show(whereLambda);
        }
        public IQueryable<T> ShowPage<type>(int pageSize, int pageIndex, bool isAsc, Expression<Func<T, type>> OrderByLambda, Expression<Func<T, bool>> WhereLambda)
        {
            return Dal.ShowPage(pageSize, pageIndex, isAsc, OrderByLambda, WhereLambda);
        }
    }
}
